package com.sefer.dragonfly.client.core.listener;

import java.io.Serializable;

import com.sefer.dragonfly.client.core.cache.CmCache;
import com.sefer.dragonfly.client.core.domain.LogData;
import com.sefer.dragonfly.client.core.listener.event.CMonitorEvent;
import com.sefer.dragonfly.client.core.listener.event.Event;
import com.sefer.dragonfly.client.tools.CmCacheTools;

public class CacheListener implements Listener {

	public void onFire(Event event) {
		if (event != null && event.getContext() != null
				&& event.getContext().getType() == CMonitorEvent.ADD_CACHE_DATA) {
			Object data = event.getContext().getData();
			if (data != null && data instanceof LogData) {
				LogData logData = (LogData) data;
				CmCache<Serializable> cache = CmCacheTools.getCache(logData
						.getCacheId());

				cache.put(logData.getObj(), logData.getTimeout());
			}
		}
	}
}
